package com.czy.ekp.cmd;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.RuntimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class CmdService {

    @Autowired
    JdbcTemplate jdbcTemplate;

    private CmdModel getModelById(String id){
        Map data = jdbcTemplate.queryForMap("select * from cmd_info where id = ?", new Object[]{id});
        return BeanUtil.mapToBean(data, CmdModel.class, true);
    }




    public String exec(String id, String params){
        CmdModel cmdModel = getModelById(id);
        return RuntimeUtil.execForStr(cmdModel.getCmd());
    }


}
